<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

    </style>
</head>

<body>
    <script>
        
        function col(p = true) {
            if (p==true) {
                let k = []
                for (l = 1; l <= 3; l++) {
                    k.push(Math.floor(Math.random() * 255))
                }
                return document.write(`
                <div style="width: 100px; height: 100px; background-color: rgb(${k});"></div>
            `)
                console.log(k);
            } else {
                let arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']
                let k = ''
                for (l = 1; l <= 6; l++) {
                    k += arr[Math.floor(Math.random() * 15)]
                } 
                return document.write(`
                <div style="width: 100px; height: 100px; background-color: #${k};"></div>
            `)
                console.log('#' + k);
            }
        }
        col(false)
        </script> 
</body>

</html>